home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
apidev
/
dax1.exe
/
DAP
/
DAPE
/
DAPSTAT.C
< prev
next >
Wrap
Text File
|
1992-07-15
|
5KB
|
147 lines
// ╔════════════════════════════════════════════════════════════════════╗
// ║ ║
// ║ module: dapstat.c ║
// ║ abstract: This module contains the support for printing some ║
// ║ stats on the server screen. If the constant ║
// ║ DAPSTATISTICS is FALSE, this module contains nothing. ║
// ║ ║
// ║ environment: NetWare 3.x v3.11 ║
// ║ Network C for NLMs SDK ║
// ║ CLib v3.11 ║
// ║ ║
// ║ This software is provided as is and carries no warranty ║
// ║ whatsoever. Novell disclaims and excludes any and all implied ║
// ║ warranties of merchantability, title and fitness for a particular ║
// ║ purpose. Novell does not warrant that the software will satisfy ║
// ║ your requirements or that the software is without defect or error ║
// ║ or that operation of the software will be uninterrupted. You are ║
// ║ using the software at your risk. The software is not a product ║
// ║ of Novell, Inc. or any of subsidiaries. ║
// ║ ║
// ╟────────────────────────────────────────────────────────────────────╢
// ║ maintenance history: ║
// ║ level date pi description ║
// ╟────────────────────────────────────────────────────────────────────╢
// ║ 001 03/03/92 kl initial release. ║
// ╚════════════════════════════════════════════════════════════════════╝
#include <stdio.h>
#include <string.h>
#include <process.h>
#include <errno.h>
#include <library.h>
#include "dap/dapsys.h"
#if DAPSTATISTICS
STATIC LONG statThreadID;
//
// number of clients w/allocated session
//
DAPSTAT DAPActiveSessions = {0,1,1,0,"Active Sessions"};
//
// total number of requests processed
//
DAPSTAT DAPTotalRequests = {0,1,2,0," Total Requests"};
//
// total number of login requests
//
DAPSTAT DAPLoginRequests = {0,1,1,29,"Logins"};
//
// total number of requests processed
//
DAPSTAT DAPLogoutRequests = {0,1,2,28,"Logouts"};
//
// highest number of transactions per second
//
DAPSTAT DAPTPSPeak = {0,1,1,50,"Peak Transactions/Sec"};
//
// current number of transactions per second
//
DAPSTAT DAPTPSCurrent = {0,1,2,47,"Current Transactions/Sec"};
//
// This is the thread which prints statistics on the server screen.
// It uses lines 1 thru 4 on the screen.
//
STATIC void DAPUpdateScreenStats(void *threadID)
{
LONG lastTotal = 0;
#define SuspendOrStop() if(!*(LONG *)threadID){ExitThread(EXIT_THREAD,0);}
#define UpdateScreen(x) if(x.updated){x.updated = FALSE; DAPatprintf(x.row,x.col,"%s: %-5d",x.desc,x.value);}
*(LONG *)threadID = GetThreadID();
while( 1 ){
//
// Delay 1 second waiting for changes
//
delay(1000);
SuspendOrStop();
//
// Figure the peak and current TPS
//
if( DAPTotalRequests.updated ){
DAPTPSCurrent.value = DAPTotalRequests.value - lastTotal;
lastTotal = DAPTotalRequests.value;
DAPTPSCurrent.updated |= 1;
if( DAPTPSCurrent.value > DAPTPSPeak.value ){
DAPTPSPeak.value = DAPTPSCurrent.value;
DAPTPSPeak.updated |= 1;
}
}
else{
DAPTPSCurrent.value = 0;
DAPTPSCurrent.updated |= 1;
}
//
// Now update the needed figures on the screen
//
UpdateScreen(DAPActiveSessions);
UpdateScreen(DAPTotalRequests);
UpdateScreen(DAPLoginRequests);
UpdateScreen(DAPLogoutRequests);
UpdateScreen(DAPTPSPeak);
UpdateScreen(DAPTPSCurrent);
SuspendOrStop();
}
}
T_RC DAPInitializeStatLogic()
{
char *divider = "────────────────────────────────────────────────────────────────────────────────";
if( BeginThread(DAPUpdateScreenStats,NULL,8192,&statThreadID) == EFAILURE ){
DIAG4("Could not start UpdateScreenStats thread");
return DAP_RESOURCE_ERROR;
}
DAPatprintf(0,0,divider);
DAPatprintf(0,28,"┤ DAP Engine Statistics ├");
DAPatprintf(3,0,divider);
DAPatprintf(23,0,divider);
ThreadSwitch(); // let the thread run once...
DIAG4("DAP Stat Logic has been initialized");
return DAP_SUCCESS;
}
void DAPDeInitializeStatLogic()
{
if( statThreadID ){
statThreadID = 0; // signal thread to shut down ...
}
DIAG4("DAP Stat Logic has been DE-initialized");
}
#endif